import React from 'react'

class Form extends React.Component {
  constructor() {
    super()
    this.inputRef = React.createRef()
  }

  onChange = () => {
    console.dir(this.inputRef.current)
  }

  focusOnInput = () => {
    this.inputRef.current.focus();
  }

  render() {
    return (
      <React.Fragment>
        <form>
          <input name="name" ref={this.inputRef} onChange={this.onChange} />
          <span onClick={this.focusOnInput}>focus</span>
        </form>
      </React.Fragment>
    )
  }
}

export default Form;
